import {
  QueryFilter,
  LightFilter,
  ProFormText,
  ProFormRadio,
  ProFormSelect,
  ProFormDigit,
  ProFormSwitch,
  ProFormDatePicker,
  ProFormDateRangePicker,
  ProFormDateTimePicker,
  ProFormTimePicker,
  ProFormSlider,
  ProFormFieldSet,
} from '@ant-design/pro-form';
import df from '../../../config/dataFormat';
import com from '../../utils/common';


export default (props) => {
  const { onFinish,def } = props;
  return (
    <LightFilter onFinish={onFinish} initialValues={def}>
      {df.keys.map((key, id) => {
        var item = df.data_type[key];
        if (item.search)
          switch (item.type) {
            case 'radio':
              return (
                <ProFormSelect
                  key={id}
                  name={key}
                  label={key}
                  placeholder={key}
                  valueEnum={com.get_select_op(item.defVal)}
                  secondary={item.secondary}
                />
              );
            case 'date':
              return <ProFormDatePicker key={id} name={key} label={key} />;
            default:
              return (
                <ProFormText
                  key={id}
                  name={key}
                  label={key}
                  placeholder={key}
                  secondary={item.secondary}
                />
              );
          }
      })}
      <ProFormDatePicker name={'录入时间'} label={'录入时间'} />
    </LightFilter>
  );
};
